package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsGoodsAttributeMapper;
import com.qf.mapper.DtsGoodsProductMapper;
import com.qf.pojo.DtsGoodsAttribute;
import com.qf.pojo.DtsGoodsProduct;
import com.qf.service.DtsGoodsAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Zwnan
 */
@Service
public class DtsGoodsAttributeServiceImpl implements DtsGoodsAttributeService {

    @Autowired
    private DtsGoodsAttributeMapper dtsGoodsAttributeMapper;


    @Override
    public void insert(DtsGoodsAttribute[] attributes) {
        for (DtsGoodsAttribute attribute : attributes) {
            dtsGoodsAttributeMapper.insert(attribute);
        }
    }

    @Override
    public List<DtsGoodsAttribute> findByGoodId(Integer id) {
        QueryWrapper<DtsGoodsAttribute> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("goods_id", id);
        queryWrapper.eq("deleted", false);

        return dtsGoodsAttributeMapper.selectList(queryWrapper);
    }

    @Override
    public void update(DtsGoodsAttribute attribute) {
        dtsGoodsAttributeMapper.updateById(attribute);
    }

    @Override
    public void deleteByGid(Integer gid) {
        dtsGoodsAttributeMapper.updateByGid(gid);
    }
}
